package com.afalon.cloud.contracts.system;

import java.net.URI;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.afalon.cloud.contracts.directory.Person;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@XmlRootElement(name = "user")
@XmlAccessorType(XmlAccessType.NONE)
public class User {

	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key userKey;
	
	@XmlElement
	@Persistent
	private String logon;
	
	@XmlElement
	@Persistent
	private String password;
		
	@Persistent
	private Person person;
	
	@XmlElement(name="useruri")
	public URI userUri;
	
	public User() 
	{
		//logon="logontest";
	}

	public Key getUserKey() {
		return userKey;
	}
	
	@XmlElement(name="userid")
	public String getUserId() {
		return KeyFactory.keyToString(this.getUserKey());
	}
		
	public void setLogon(String value) {
		logon = value;
	}

	public String getLogon() {
		return logon;
	}
	
	public void setPassword(String value) {
		password = value;
	}

	public String getPassword() {
		return password;
	}

	public void setPerson(Person value) {
		person = value;
	}

	
	public Person getPerson() {
		return person;
	}
	
	
	@XmlElement(name="personid")
	public String getPersionId() {
		return person!=null ? person.getPersonId() : null;
	}
	
	
}

